package dict

type ReportTypeId string

var ReportTypeEnable = make(map[ReportType][]AdProductType)

var ReportTypeIdList = make(map[string]string)

func _genRptTypeKey(reportType ReportType, product AdProductType) string {
	return product.Name + string(reportType)
}

func _addReportTypeId(reportType ReportType, product AdProductType, value string) {
	var key = _genRptTypeKey(reportType, product)
	ReportTypeIdList[key] = value
	_addReportTypeEnable(reportType, product)
}

func _addReportTypeEnable(reportType ReportType, product AdProductType) {
	var list, ok = ReportTypeEnable[reportType]
	if !ok {
		list = []AdProductType{}
		ReportTypeEnable[reportType] = list
	}
	list = append(list, product)
}

func GetReportTypeId(reportType ReportType, product AdProductType) ReportTypeId {
	var key = _genRptTypeKey(reportType, product)
	return ReportTypeId(ReportTypeIdList[key])
}

func init() {
	_addReportTypeId(Campaign, AdProduct, "spCampaigns")
	_addReportTypeId(Campaign, AdBrand, "sbCampaigns")
	_addReportTypeId(Campaign, AdDisplay, "sdCampaigns")

	_addReportTypeId(AdGroup, AdBrand, "sbAdGroup")
	_addReportTypeId(AdGroup, AdDisplay, "sdAdGroup")

	_addReportTypeId(Audience, AdProduct, "spGlobalAudiences")
	_addReportTypeId(Audience, AdBrand, "sbAudiences")

	_addReportTypeId(Placement, AdBrand, "sbCampaignPlacement")

	_addReportTypeId(Targeting, AdProduct, "spTargeting")
	_addReportTypeId(Targeting, AdBrand, "sbTargeting")
	_addReportTypeId(Targeting, AdDisplay, "sdTargeting")

	_addReportTypeId(SearchTerm, AdProduct, "spSearchTerm")
	_addReportTypeId(SearchTerm, AdBrand, "sbSearchTerm")

	_addReportTypeId(AdvertisedProduct, AdProduct, "spAdvertisedProduct")
	_addReportTypeId(AdvertisedProduct, AdDisplay, "sdAdvertisedProduct")

	_addReportTypeId(Ad, AdBrand, "sbAds")

	_addReportTypeId(PurchasedProduct, AdProduct, "spPurchasedProduct")
	_addReportTypeId(PurchasedProduct, AdBrand, "sbPurchasedProduct")
	_addReportTypeId(PurchasedProduct, AdDisplay, "sdPurchasedProduct")

	_addReportTypeId(GrossAndValidTraffic, AdProduct, "spGrossAndInvalids")
	_addReportTypeId(GrossAndValidTraffic, AdBrand, "sbGrossAndInvalids")
	_addReportTypeId(GrossAndValidTraffic, AdDisplay, "sdGrossAndInvalids")
}
